// preparestructuralestimation.do

// prepare dataset for structural estimation

clear
clear matrix
capture set memory 10g
capture set maxvar 32767
capture set matsize 11000

do prepare.do

keep  countrycode upstream downstream fraction delta delta_t n_div_gm n_div_f
sort  countrycode upstream downstream fraction delta delta_t n_div_gm n_div_f
order countrycode upstream downstream fraction delta delta_t n_div_gm n_div_f

outsheet using data/dataset.csv, replace nolabel comma

clear
clear matrix
capture set memory 10g
capture set maxvar 32767
capture set matsize 11000

do prepare.do

gen denom_gm = numberOfCases / n_div_gm
gen denom_f = numberOfCases / n_div_f

keep  countrycode upstream downstream fraction delta delta_t numberOfCases denom_gm denom_f
sort  countrycode upstream downstream fraction delta delta_t numberOfCases denom_gm denom_f
order countrycode upstream downstream fraction delta delta_t numberOfCases denom_gm denom_f

outsheet using data/dataset_bootstrap.csv, replace nolabel comma
